package com.lib.controller.user;

import com.lib.pojo.VO.CategoryVO;
import com.lib.pojo.entity.Result;
import com.lib.service.SearchService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Tag(name = "搜索功能-模糊查询")
@RequestMapping("/user/books")
@Slf4j
public class SearchController {
    @Autowired
    private SearchService searchService;

    //1：模糊搜索图书名
    @GetMapping("/search")
    @Operation(summary = "模糊搜索图书名")
    public Result<List<CategoryVO>> searchBook(String keyword){
        List<CategoryVO> categoryVOS = searchService.searchBookById(keyword);
        return Result.success(categoryVOS);
    }
}
